<template>
	<view>
		<uni-search-bar placeholder="搜索巴士"></uni-search-bar>
		<view class="u-demo">
			<uni-card v-for="(item,index) in bashi" :title="item.name">
				<view @click="dian(item.id)">
					<view style="color: #F29100;">首：{{item.startTime}} ———— 末：{{item.endTime}}</view>
					<view>票价：{{item.price}}元</view>
					<view>里程:{{item.mileage}}</view>
				</view>
				<uni-collapse>
					<uni-collapse-item :title="item.first+'————'+item.end">
						<uni-steps :options="steps[index]" direction="column"></uni-steps>
					</uni-collapse-item>
				</uni-collapse>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base:api.baseurl,
				bashi:'',
				steps:[]
			}
		},
		onLoad() {
			this.getlun()
		},
		onBackPress() {
			uni.switchTab({
				url:'../allserver'
			})
			return true
		},
		methods: {
			dian(id){
				uni.navigateTo({
					url:'ban1?id='+id
				})
			},
			getlun(){
				this.$get(this.base+'/prod-api/api/bus/line/list').then((res)=>{
					this.bashi = res.rows
					const _this = this
					var i = 0
					getshu()
					function getshu(){
						if(i>=res.rows.length){
							return 
						}
						_this.$get(_this.base+'/prod-api/api/bus/stop/list',{
							linesId:res.rows[i].id
						}).then((res)=>{
							let list =[]
							res.rows.forEach((item)=>{
								list.push({
									title:item.name
								})
							})
							_this.$set(_this.steps,i,list)
							i++
							getshu()
						})
					}
				})
			},
		}
	}
</script>

<style>

</style>
